import { defineStore } from 'pinia'
import { ref } from 'vue'

// 定义 Store
export const useShopStore = defineStore(
  'shop',
  () => {
    //店铺信息
    const shop = ref({})
    //店铺ID
    const shopId = ref(0)
    //保存用户信息
    const setShop = (val) =>{
      shop.value = val
    }
    //保存用户选择店铺的ID
    const setShopId = (val) => {
      shopId.value = val
    }
    // 清理店铺信息，删除时使用
    const clearShop = () => {
      shop.value = undefined
    }

    // 记得 return
    return {
      shop,
      shopId,
      setShop,
      clearShop,
      setShopId
    }
  },
  // TODO: 持久化
  {
    persist: true,
  },
)